<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
    <title>角色管理</title>
    <script type="text/javascript" src="../js/common.js"></script>
</head>
<body>
<div class="pd-20">
    <div class="panel-body" style="padding-bottom:0px;">
        <div class="panel panel-default">
            <div class="panel-heading">查询条件</div>
            <div class="panel-body">
                <form id="form" class="form-horizontal">
                    <div class="form-group" style="margin-top:15px">
                        <label class="control-label col-sm-2">角色名称:</label>
                        <div class="col-sm-3">
                            <input name="role" type="text" class="form-control">
                        </div>
                        <label class="control-label col-sm-2">状态:</label>
                        <div class="col-sm-3">
                            <select name="state" class="form-control">
                                <option value="">请选择</option>
                                <option value="1">可用</option>
                                <option value="2">不可用</option>
                            </select>
                        </div>
                        <div class="col-sm-2" style="text-align:left;">
                            <button type="button" class="btn btn-info" onclick="search('/role/')"><i
                                    class="glyphicon glyphicon-search"></i>搜索
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>


    <div id="toolbar" class="btn-group">
    </div>
    <table id="table"></table>
</div>

<script type="text/javascript">
    var menu_id = getQueryVariable("menu_id");
    loadButton(menu_id, "toolbar");
    var columns = [{
        checkbox: true
    }, {
        field: 'id',
        title: 'id',
        align: 'center'
    }, {
        field: 'role',
        title: '角色',
        align: 'center'
    }, {
        field: 'description',
        title: '描述',
        align: 'center'
    }, {
        field: 'state',
        title: '状态',
        align: 'center',
        formatter: function (value, row, index) {
            if (value == 1) {
                return '可用';
            } else if (value == 2) {
                return '不可用';
            }
        }
    }, {
        field: 'create_time',
        title: '创建时间',
        align: 'center'
    }];

    loadData("/role/", {}, columns);


    function add() {
        op.add('添加角色', 'role_add.html', 500, 450);
    }

    function edit() {
        op.edit('编辑角色', 'role_add.html', 500, 450);
    }
    function del() {
        op.del('/role/del');
    }

    /**
     * 授权
     */
    function authorise() {
        var rows = $('#table').bootstrapTable('getSelections');
        if (rows.length == 0) {
            layer.msg("没有选择角色");
            return;
        }
        if (rows.length > 1) {
            layer.msg("只能选择一个角色");
            return;
        }
        var row = rows[0];
        window.sessionStorage.setItem("row", JSON.stringify(row));
        layer_show('授权', 'role_authorise.html?id=' + row.id, 900, 700);
    }
</script>
</body>
</html>
